$(document).ready(function(){		    
	var contentPane = $('#ContentPane');
	contentPane.find('.icon-drag').draggable({
		scope: 'article',
		helper: function(){
			return $('<div class="move-container"><?php echo Mozg_Lang::_('moving'); ?>: '+$(this).data('title')+'</div>').appendTo('body');			
		},			
		cursorAt: {top:2, left:-10},
		zIndex: 1000,
		iframeFix: true,
		addClasses: false
	});
	
	var rightPane = $('#RightPane');
	var themeList = rightPane.find('table.edit_block > tbody').first();
	rightPane.find('.ui-layout-content').droppable({
		scope: 'article',
		tolerance: 'pointer',
		drop: function(ev, ui) {
	
	        drag_id = ui.draggable.data('id');
			drop_id = $('#themeArticle').data('id');

			$.ajax( {url: "<?=htmlspecialchars(Mozg::Router('http')->Create('module=admin&ctrl=' .$this->ctrlName. '&action=savetheme'));?>",
				dataType: 'json',
				type: 'POST',
				data: {'blog': '<?php echo $this->blog->GetId(); ?>', 'id': drop_id, 'theme_id': drag_id},
				success:function (data){
							HandleResponseJSON(data, function(data){
								themeList.append(data);
							});
						}
			} );			
			
			return false;
		}
	});
	
	rightPane.find('a.del').live('click', function(){
		
		var but = $(this);
		
		$.ajax( {url: this.href,
			dataType: 'json',
			type: 'GET',
			success:function (data){
						HandleResponseJSON(data, function(data){
							but.closest('tr.active-container').remove();
						});
					}
		} );		
		
		return false;
	});
	
});